package com.car.rental.vehicle.enums;

import lombok.Getter;
import com.car.rental.common.core.exception.BusinessException;

@Getter
public enum VehicleStatus {
    MAINTENANCE(0, "维修中"),
    AVAILABLE(1, "可用"),
    RENTED(2, "已租");
    
    private final Integer code;
    private final String description;
    
    VehicleStatus(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    public static VehicleStatus fromCode(Integer code) {
        for (VehicleStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new BusinessException("无效的车辆状态: " + code);
    }
} 